home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0696A.ZIP
/
GETPNAME.C
< prev
next >
Wrap
Text File
|
1987-05-04
|
844b
|
30 lines
/**
* getpname-- extract the baser name of a program from the
* pathname string (deletes a drive specifier, any leading
* path node information, and the extension)
**/
#include <stdio.h>
#include <ctype.h>
void getpname(path, pname)
char *path; /* full or relative pathname */
char *pname; /* program name pointer */
{
char *cp;
/* find the end of the pathname string */
cp = path; /* start of the pathname */
while (*cp != '\0')
++cp;
--cp; /* one too far ( at 0) */
/* find the start of the filename part */
while (cp>path && *cp != '\\' && *cp != ':'&& *cp != '/')
--cp;
if (cp > path)
++cp; /* move to right of pathname separator */
/* copy the filename part only */
while ((*pname = tolower(*cp)) != '.' && *pname != '\0') {
++cp;
++pname;
}
*pname = '\0';
}